<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>开启/关闭自动渲染功能</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="class.yaf-dispatcher.html">Yaf_Dispatcher</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="yaf-dispatcher.catchexception.html">Yaf_Dispatcher::catchException</a></div>
 <div class="up"><a href="class.yaf-dispatcher.html">Yaf_Dispatcher</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="yaf-dispatcher.autorender" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Yaf_Dispatcher::autoRender</h1>
  <p class="verinfo">(Yaf &gt;=1.0.0)</p><p class="refpurpose"><span class="refname">Yaf_Dispatcher::autoRender</span> &mdash; <span class="dc-title">开启/关闭自动渲染功能</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-yaf-dispatcher.autorender-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type"><a href="class.yaf-dispatcher.html" class="type Yaf_Dispatcher">Yaf_Dispatcher</a></span> <span class="methodname"><strong>Yaf_Dispatcher::autoRender</strong></span>
    ( <span class="methodparam"><span class="type">bool</span> <code class="parameter">$flag</code></span>
   )</div>

  <p class="para rdfs-comment">
   在开启的情况下(Yaf默认开启)，action执行完成以后，<a href="class.yaf-dispatcher.html" class="classname">Yaf_Dispatcher</a> 会自动调用view引擎去渲染该action对应的视图模板。
   你也可以通过调用这个函数并将 <em><code class="parameter">flag</code></em> 参数的值设为TRUE来人工干预它。
   <blockquote class="note"><p><strong class="note">Note</strong>: 
     <p class="para">
     你可以在一个action中仅仅返回FALSE来阻止当前action对应视图的自动渲染
    </p>
   </p></blockquote>
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-yaf-dispatcher.autorender-parameters">
  <h3 class="title">参数</h3>
  <dl>

   
    <dt>
<em><code class="parameter">flag</code></em></dt>

    <dd>

     <p class="para">
       bool
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-yaf-dispatcher.autorender-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-yaf-dispatcher.autorender-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-4031">
   <p><strong>Example #1 <span class="function"><strong>Yaf_Dispatcher::autoRender()</strong></span>example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">IndexController&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">Yaf_Controller_Abstract&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">/*&nbsp;init&nbsp;method&nbsp;will&nbsp;be&nbsp;called&nbsp;as&nbsp;soon&nbsp;as&nbsp;a&nbsp;controller&nbsp;is&nbsp;initialized&nbsp;*/&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">public&nbsp;function&nbsp;</span><span style="color: #0000BB">init</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getRequest</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">isXmlHttpRequest</span><span style="color: #007700">())&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//do&nbsp;not&nbsp;call&nbsp;render&nbsp;for&nbsp;ajax&nbsp;request<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//we&nbsp;will&nbsp;outpu&nbsp;a&nbsp;json&nbsp;string<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">Yaf_Dispatcher</span><span style="color: #007700">::</span><span style="color: #0000BB">getInstance</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">autoRender</span><span style="color: #007700">(</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<br /><br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
</pre></div>
   </div>
  </div>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="class.yaf-dispatcher.html">Yaf_Dispatcher</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="yaf-dispatcher.catchexception.html">Yaf_Dispatcher::catchException</a></div>
 <div class="up"><a href="class.yaf-dispatcher.html">Yaf_Dispatcher</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
